import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

// import Home from '@/pages/home/Home.vue'
// import AppealCenter from '@/pages/businesscenter/AppealCenter.vue'
// import SelectPath from '@/pages/assignment/SelectPath.vue'
// import SetUpInfo from '@/pages/assignment/SetUpInfo.vue'
// import ActivityList from '@/pages/assignment/ActivityList.vue'
// import Detail from '@/pages/funds/Detail.vue'
// import BindStore from '@/pages/setting/BindStore.vue'
// import Login from "@/pages/login/login.vue";
// import set from "@/pages/setting/forget.vue";
// import password from "@/pages/setting/index.vue";
// import Appeal from '@/pages/appeal/Appeal.vue'
// import Recharge from '@/pages/recharge/Recharge.vue'
// import OrderList from '@/pages/orderlist/OrderList.vue'


const Home = () => import('@/pages/home/Home.vue')
const AppealCenter = () => import('@/pages/businesscenter/AppealCenter.vue')
const SelectPath = () => import('@/pages/assignment/SelectPath.vue')
const SetUpInfo = () => import('@/pages/assignment/SetUpInfo.vue')
const ActivityList = () => import('@/pages/assignment/ActivityList.vue')
const Detail = () => import('@/pages/funds/Detail.vue')
const BindStore = () => import('@/pages/setting/BindStore.vue')
const Login = () => import("@/pages/login/login.vue")
const set = () => import("@/pages/setting/forget.vue")
const password = () => import("@/pages/setting/index.vue")
const Appeal = () => import('@/pages/appeal/Appeal.vue')
const Recharge = () => import('@/pages/recharge/Recharge.vue')
const OrderList = () => import('@/pages/orderlist/OrderList.vue')
const test = () => import('@/pages/test.vue')







const router = new Router({
  mode:'history',
  routes: [
    // {
    //   path:"/test",
    //   name:"test",
    //   component:test
    // },
    {
      path: '/',
      name: 'Home',
      component: Home,
      redirect: { path: '/appealcenter' },
      children: [
        {
          path: 'appealcenter',
          name: 'AppealCenter',
          component: AppealCenter
        },
        {
          path: 'selectpath',
          name: 'SelectPath',
          component: SelectPath
        },
        {
          path: 'password',
          name: 'password',
          component: password,
        },
        {
          path: 'setupinfo',
          name: 'SetUpInfo',
          component: SetUpInfo
        },
        {
          path: 'activitylist',
          name: 'ActivityList',
          component: ActivityList
        },
        {
          path: 'detail',
          name: 'Detail',
          component: Detail
        },
        {
          path: 'bindstore',
          name: 'BindStore',
          component: BindStore
        },
        {
          path:'appeal',
          name:'Appeal',
          component:Appeal
        },
        {
          path:"recharge",
          name:'Recharge',
          component:Recharge
        },
        {
          path:'orderlist',
          name:'OrderList',
          component:OrderList,
        }
      ]
    },
    {
      path: '/login',
      name:'login',
      component: Login,
    },
    {
      //找回密码
      path: '/set',
      name:'set',
      component: set,
    },
  ]
})
const beforeEach = function beforeEach(to, from, next) {
     let userKey = localStorage.getItem('userKey')
     if(userKey){
        next()
     }else{
        if(to.path == '/login' || to.path == '/set'){
           next()
        }else{
           next({
              path:'/login'
           })
        }
     }
}
router.beforeEach(beforeEach);
export default router;
